package com.ramesh.fragmenttabhostdemo;


import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;




public class CustomSpinnerAdapter extends ArrayAdapter<String> {

	String[] m_objects;
	public CustomSpinnerAdapter(Context context, int textViewResourceId, String[] objects) 
	{
		super(context, textViewResourceId, objects);
		m_objects = objects;
	}

    @Override
    public View getView(int position, View convertView, ViewGroup parent) 
    {
    return getCustomView(position, convertView, parent);
    }

 private String getShortLangName(int position) 
 {
	 if ("Armenian" == m_objects[position]) {
		 return "Am";
	 } else if ("Arabian" == m_objects[position]) {
		 return "Ar"; 
	 } else if ("English" == m_objects[position]) {
		 return "En";
	 } else if ("Franche" == m_objects[position]) {
		 return "Fr";
	 }
	 return "";
 }
 
public View getCustomView(int position, View convertView, ViewGroup parent) 
{

	LayoutInflater inflater = (LayoutInflater)getContext().getSystemService( Context.LAYOUT_INFLATER_SERVICE );
    View row=inflater.inflate(R.layout.custom_spinner, parent, false);
    TextView label=(TextView)row.findViewById(R.id.language_spinner_header);
    
    label.setText("Language : " + getShortLangName(position));
    return row;
 }
}
